layui.use(['table', 'jquery', 'layer'], function(){
    var $ = layui.$
    var table = layui.table
    var layer = layui.layer

    $('#cancel').click(function(){
        let data = table.checkStatus('sharelist').data
        if(data.length == 0){
            layer.msg('请选择需要取消的分享')
            return
        }
        layer.confirm('即将取消 '+ data.length +' 个分享，是否继续？', {closeBtn: 0, icon: 3, title:'批量取消分享'}, function(){
            let list = []
            for(i of data){
                list.push(i.sharecode)
            }
            $('#Content_Code').val(list.join(','))
            __doPostBack('ctl00$Content$doPost','')
        })
    })
    table.on('tool', function(obj){
        let data = obj.data
        if(obj.event === 'open'){
            window.open("/file.aspx?code=" + data.sharecode)
        }else if(obj.event === 'cancel'){
            layer.confirm('确认取消分享 "'+data.sharecontent+'"？', {closeBtn: 0, icon: 3, title:'取消分享'}, function(){
                $('#Content_Code').val(data.sharecode)
                __doPostBack('ctl00$Content$doPost','')
            })
        }
    })
})